/**
 * @func _转驼峰
 * @param {*} str
 */
function toCamel(str) {
  // str = str.replace(/(\w)/, (match, $1) => `${$1.toUpperCase()}`)
  while (str.match(/\w_\w/)) {
    str = str.replace(
      /(\w)(_)(\w)/,
      (match, $1, $2, $3) => `${$1}${$3.toUpperCase()}`
    )
  }
  return str
}

console.log(toCamel("a_b_c_def")) // aBCDef

function toCamelCase(str) {
  if (typeof str !== "string") {
    return str
  }
  return (
    str
      .split("_")
      // .map(el => el.charAt(0).toUpperCase() + el.substr(1, el.length))
      .map((item, index) => {
        if (index) {
          return item.charAt(0).toUpperCase() + item.substr(1, item.length)
        } else return item
      })
      .join("")
  )
}

console.log(toCamelCase("a_b_c_def")) // aBCDef

const fib = (n, a = 1, b = 1) => {
  if (n <= 1) return b
  return fib(n - 1, b, a + b)
}

console.log(fib(1475))
